import { method } from 'lodash'

/*
 * @Author: Quinn
 * @Date: 2023-05-19 11:40:35
 * @LastEditors: 叽歪小Q
 * @Description:
 */
const formatUrl = (url, data, config) => {
  return `${url}/${data.id}`
}

const getList = [
  '/order/getPaymentMethod', //新增订单-付款方式
  '/broken/deleteBroken', //报损单-删除
  '/broken/rejectBroken', //修改报损单状态-驳回
  '/broken/passBroken', //修改报损单状态-通过
  '/broken/getBrokenList', //获取报损列表
  '/broken/getBrokenDetailList', //获取单品
  '/order/getOfferDirectoryDown',
  '/storeLedger/getFinanceOneLevelTypeDto', //财务列表获取费用类型
  '/storeLedger/selectFinanceDetailsByFinanceId', //财务列表获取费用类型明细
  '/inventory/getInventoryGoodsList', //根据仓库查看产品库存
  'role/roleList',
  '/material/getMaterialInfoLikeName',
  '/order/getOrderInfoLikeName',
  '/new/areaLedger/types',
  '/areaLedger/fyTypeList',
  '/areaLedger/areaList',
  '/factory/getFactoryList', //工厂列表
  '/new/areaLedger/list',
  '/new/storeLedger/stores',
  '/new/storeLedger/types',
  '/new/storeLedger/list',
  '/new/order/costs',
  '/new/finance/list',
  '/new/finance/reject/list',
  '/new/cad/parse/texts',
  '/new/cad/parse/result',
  '/new/afterSale/materials',
  '/material/inout/materials',
  '/new/order/out/materials',
  '/new/order/material/list',
  '/new/order/addition/list',
  '/new/order/storage/list',
  '/new/payment/list',
  '/afterSale/list',
  '/new/install/list',
  '/material/material/addition/list',
  '/new/province/enum',
  '/new/afterSaleTypes/enum',
  '/inStorage/inStorageList',
  '/areaLedger/areaLedgerList',
  '/storeLedger/storeLedgerList',
  '/areaLedger/areaListNew', //不受权限控制的仓库列表
  '/inventory/getLocationName', //库位列表
  '/user/userList',
  '/home/getHomeSellInfo',
  '/inventory/inventoryList',
  '/order/additionList',
  '/order/orderAdditionDetail',
  '/order/paymentDetials',
  '/order/installers',
  '/order/goodsDirectorys',
  '/order/orderAdditionDetail',
  '/user/userInfo',
  '/home/getHomeAfterSaleInfo',
  '/home/getHomePageInfo',
  '/check/checkList', //盘点列表
  '/purchase/getFactoryOutList', //查询工厂库存列表
  '/purchase/getAreaPutNum', //查询入库数量
  '/purchase/inspectPurchaseCompleteStatus', //查询采购订单是否已完成
  '/purchase/getFactoryInRecord', //查询修改库存记录
  '/storeLedger/getFinanceLevelTypeDto',
  '/storeLedger/getAccountName',
  '/order/getOrderExpressCharge', //财务获取订单运费
  '/storeLedger/updateSupervisorStatus', //仓库主管通过报销
  '/contract/getContractList', //查看合同列表
  '/order/selectInstallationUser', //查看施工人员列表
  '/directory/directoryList',
  '/order/submitOrder',
  '/purchase/getMaterialInfoByProductName',
  '/order/getPerOrderList', //查看施工人员列表
  '/purchase/getSupplierVo',
  '/purchase/getSupplierMaterialPrice',
  '/finance/getZymCashRegisterList',
  '/refund/getCustomerRefund', // 查看退款记录详情
  '/new/afterSaleNew/inOutMaterials', // 查看退款记录详情
  '/storeLedger/getStoreReimburseDetail',
]
const postList = [
  '/order/updateAzGoodsCount',
  '/order/updatePayStatus', //订单-修改收款到账状态
  '/order/add', //订单-录入订单(材料录入创建订单)
  '/test/decryption',
  '/factory/updateFactoryWareHousePosition',
  '/material/inventory/factoryInOutList/excleList', // 获取工厂excel文件内容列表
  '/new/afterSale/afterSaleNewOut', // 获取工厂excel文件内容列表
  '/material/inventory/factoryInOut/excle', // 确定上传
  '/refund/addCustomerRefund',
  '/finance/addDetailFee',
  '/finance/deleteDetailFee',
  '/finance/updateDetailFee',
  '/finance/getDetailList',
  '/afterSale/import/excelOut',
  '/finance/getOldStoreDetailList',
  '/finance/deleteOldStoreDetailFee',
  '/finance/updateOldStoreDetailFee',
  '/finance/addOldStoreDetailFee',
  '/purchase/calculateFinanceInfo',
  '/purchase/updateFinanceInfo',
  '/order/getMaterialCommissionSummary',
  '/order/cancelCarMaterialCommission',
  '/order/getCarMaterialCommissionNameList',
  '/order/addCarMaterialCommissionName',
  '/purchase/updateCompleteInOutStatus',
  '/purchase/purchaseMaterialAddInventory',
  '/order/cancelCommission', //取消提成
  '/order/cancelMaterialCommission', //取消材料提成
  '/order/addMaterialCommissionName', //添加材料提成
  '/order/getMaterialCommissionNameList', //材料提成列表
  '/order/getCommissionSummary', //查询总提成
  '/order/getCommissionListByType', //提成列表
  '/broken/updateBroken', //修改报损凭证
  '/order/updateIsDebt', //修改报损凭证
  '/storeLedger/updateStoreLedgerFinanceStatus2', //修改报损凭证
  '/broken/updateBroken', //报损单编辑
  '/broken/updateBroken', //报损单修改
  '/broken/addBroken', //新增报损单
  '/dashboards/getAfterSaleInfo', //
  '/dashboards/getPurchaseData', //dataContact
  '/storeLedger/updateStoreLedgerDetails', //修改报销
  '/dashboards/getBrandHistogramData', //dataContact
  '/dashboards/getAreaLineChart', //dataContact
  '/user/userInfoUpdate',
  '/user/logout',
  '/storeLedger/deleteOrUpdateStoreLedger',
  '/areaLedger/updateAreaLedgerStatus',
  '/storeLedger/addStoreLedgerDetails',
  '/inventory/getInventoryList',
  '/user/deleteUser',
  '/user/addUser',
  '/storeLedger/getStoreLedger',
  '/afterSale/updateAfterSaleInfo',
  '/areaLedger/addAreaLedger',
  '/order/addPayment',
  '/order/insertAddition',
  '/new/areaLedger/create',
  '/new/storeLedger/create',
  '/new/storeLedger/update',
  '/new/finance/reject/update',
  '/storeLedger/updateStoreLedgerFinanceStatus', //更新报销状态
  '/storeLedger/updateSupervisorStatus', //更新报销状态
  '/new/finance/delete',
  '/new/afterSale/delete',
  '/factory/getFactoryMaterialList', //工厂库存列表
  '/factory/updateFactoryInventoryNum', //修改工厂库存
  '/factory/addFactoryMaterial', //添加工厂产品
  '/purchase/getPurchaseList', //采购单列表
  '/purchase/addPurchase', //新增采购单
  '/purchase/deductionFactoryInventory', //工厂出库扣减库存
  '/purchase/purchaseMaterialAddInventory', //操作入库
  '/order/updateOrderCadUserId', //cad操作认领
  '/order/orderList',
  // "/new/order/delete",
  '/order/orderDelete',
  '/single/addSingle', //单品出库新增
  '/single/getSingleList', //单品出库新增
  '/single/updateSingle', //单品出库编辑
  '/single/singleOutInventory', //单品出库扣库存
  '/allot/addAllotMaterial', //调货新增
  '/allot/getAllotMaterial', //调货列表
  '/allot/updateOutProofByAllotNo', //上传调出凭证
  '/allot/updateAllotMaterial', //编辑调货单
  '/allot/allotOutAndInInventory', //调货单确认完成
  '/check/checkAdd', //新增盘点单
  '/check/updateStatus', //改变盘点状态
  '/check/checkDelete', //删除
  '/inventory/updateLocationName', //编辑库位
  '/purchase/purchaseMaterialAddInventory', //采购单入库
  '/purchase/deletePurchase', //删除采购单
  '/purchase/updatePurchaseStatus', //审核采购单
  '/new/finance/update',
  '/new/afterSale/update',
  '/order/confirmOrder', //订单列表 确认订单锁库存
  '/order/outNew', //订单出库
  '/inventory/updateInventoryWarningNum', //订单出库
  '/purchase/updateDamageNum', //采购单仓库报损
  '/purchase/updateDamageStatus', //采购单工厂确认报损
  '/purchase/updatePurchaseData', //修改采购单
  '/order/CancelRollbackInventory', //回滚订单列表库存
  '/order/getSmsSendRecordList', //短信预警列表
  '/factory/updateFactoryWarningNum', //工厂库存预警
  '/new/install/create',
  '/new/afterSale/create',
  '/new/payment/create',
  '/new/order/create',
  '/new/order/update',
  '/new/order/out',
  '/new/cad/parse',
  '/order/orderInfoUpdate',
  '/order/addInstaller',
  '/afterSale/afterSaleAdd',
  '/storeLedger/updateStoreLedger',
  '/storeLedger/updateStoreLedgerStatus',
  '/areaLedger/deleteOrUpdateAreaLedger',
  '/order/closeOrderReimbursement', //关闭报销订单
  '/order/cancelContract', //关闭报销订单
  '/single/getSingleListDetail', //单品出库
  '/purchase/import/excel', //新增采购单-导入excle
  '/material/inventory/purchaseImport/execl', //导入库存
  '/purchase/import/excelFeedback', //上传excel回显里面的内容
  '/afterSale/getAfterSaleNewList',
  '/afterSale/addAfterSaleNew',
  '/afterSale/deleteAfterSaleNew',
  '/afterSale/updateAfterSaleNewInfo',
  '/purchase/productAndSupplier', //单条产品与供应商绑定
  '/order/confirmOrderSenior',
  '/finance/getZymAddOrderList', //查询zym增加单列表
  '/finance/addZymAddOrder', //新增zym增加单
  '/finance/deleteZymAddOrder', //删除zym增加单
  '/finance/updateZymAddOrder', //更新zym增加单
  '/finance/getZymCashRegisterList',
  '/finance/addZymCashRegister',
  '/finance/deleteZymCashRegister',
  '/finance/updateZymCashRegister',
]

const initApi = (arr, method = 'get') => {
  const res = {}
  arr.forEach((url) => {
    const key = url
      .split('/')
      .filter((e) => e)
      .map((str, index) => {
        if (index > 0) return str.slice(0, 1).toUpperCase() + str.slice(1)
        return str
      })
      .join('')
    res[key] = {
      url,
      method,
    }
    if (method == 'post') res[key]['contentType'] = 'application/json'
  })
  return res
}

export default {
  ...initApi(getList),
  ...initApi(postList, 'post'),
  login: {
    url: '/user/login',
  },
  getAccountInfo: {
    url: '/account',
    method: 'get',
    formatUrl,
  },
  deleteRole: {
    url: '/role',
    method: 'delete',
    formatUrl,
  },
  addRole: {
    url: '/role',
    method: 'post',
  },
  getRole: {
    url: '/role/roleList',
    method: 'get',
  },
  patchRole: {
    url: '/role',
    method: 'patch',
    formatUrl,
  },
  getLeaders: {
    url: '/account/managers/list',
    method: 'get',
  },
  getAzItem: {
    url: '/order/selectInstallationUser',
    method: 'get',
  },
  getAccount: {
    url: '/user/userList',
    method: 'get',
  },
  updatePsd: {
    url: '/account/update_password',
    method: 'post',
  },
  addAccount: {
    url: '/account',
    method: 'post',
    contentType: 'application/json',
  },
  setAccountRole: {
    url: '/account_role',
    method: 'post',
    contentType: 'application/json',
  },
  patchAccount: {
    url: '/account',
    method: 'patch',
    formatUrl,
  },
  deleteAccount: {
    url: '/account',
    method: 'delete',
    formatUrl,
  },
  getInventoryWarn: {
    url: '/material/inventory/alarm',
    method: 'get',
  },
  getInventory: {
    url: '/inventory/getInventoryList',
    method: 'post',
  },
  patchInventory: {
    url: '/material/inventory/update',
    method: 'post',
    contentType: 'application/json',
  },
  getInout: {
    url: '/inout/inOutRecordList',
    method: 'post',
  },
  inoutUpdate: {
    url: '/order/out',
    contentType: 'application/json',
    method: 'post',
  },
  addInout: {
    url: '/material/inout',
    method: 'post',
    contentType: 'application/json',
  },
  addMaterial: {
    url: '/material',
    contentType: 'application/json',
  },
  editMaterial: {
    url: '/material',
    contentType: 'application/json',
  },
  patchMaterial: {
    url: '/material/updateMaterialStatus',
    method: 'post',
    contentType: 'application/json',
  },
  updateMaterial: {
    url: '/material/materialUpdate',
    method: 'post',
    contentType: 'application/json',
  },
  deleteMaterial: {
    url: '/material/delMaterial',
    method: 'post',
    contentType: 'application/json',
  },
  qrcodeMaterial: {
    url: '/material/qrcode',
    method: 'get',
  },
  getMaterial: {
    url: '/material/queryMaterialPage',
    method: 'get',
  },
  getInstall: {
    url: '/order/install/list',
    method: 'get',
  },
  getOrderQuotation: {
    url: '/order/quotation',
    method: 'get',
  },
  getQuoteMaterials: {
    url: '/order/quotation/materials',
    method: 'get',
  },
  createQuotation: {
    url: '/order/quotation',
    method: 'post',
    contentType: 'application/json',
    formatUrl,
  },
  getExtraOrder: {
    url: '/order/extraOrder',
    method: 'get',
  },
  patchExtraOrder: {
    url: '/order/extraOrder',
    method: 'post',
    contentType: 'application/json',
    formatUrl,
  },
  orderList: {
    url: '/order/orderList',
    method: 'post',
  },
  orderDetail: {
    url: '/order/detail',
    method: 'get',
    formatUrl,
  },
  upload: {
    url: '/common/upload',
    method: 'post',
    contentType: 'multipart/form-data',
  },
  patchOrder: {
    url: '/order',
    method: 'post',
    contentType: 'application/json',
    formatUrl,
  },
  orderFlow: {
    url: '/order/orderFlow',
    method: 'get',
  },
  orderLine: {
    url: '/order/order/line',
    method: 'get',
  },
  addDirectory: {
    url: '/directory/addDirectory',
  },
  impInventoryExcel: {
    url: '/material/inventory/import/execl',
  },
  getDirectory: {
    url: '/directory/directoryList',
    method: 'get',
  },
  patchDirectory: {
    url: '/directory/updateDirectory',
    method: 'post',
    contentType: 'application/json',
    // formatUrl,
  },
  deleteDirectory: {
    url: '/directory/deleteDirectory',
    method: 'post',
  },
}
